@echo off

setlocal
set download_dir=%1


set component_name=AgfaHC.Ris.Web.Services.Setup
set new_dir=%component_name%

if "%download_dir%" == "" (
   echo No download_dir specified. Abort!
   goto :EOF
)

if not exist %download_dir% (
   echo No %download_dir% directory. Abort!
   goto :EOF
)

set msi_file=%download_dir%\..\AgfaHC.Ris.Web.Services.msi
set msm_file=%download_dir%\..\AgfaHC.Ris.Web.Services.msm

if not exist %msm_file% (
   echo No %msm_file%. Abort!
   goto :EOF
)

if not exist %msi_file% (
   echo No %msi_file%. Abort!
   goto :EOF
)

if not exist %new_dir% (
   echo New component directory %new_dir% doesn't exist. Abort!
   goto :EOF
)

chmod -R +w %new_dir%

echo Copying MSM and MSI files
set pkg_dir=%new_dir%\pkg\win32\Release
copy %msm_file% %pkg_dir%
copy %msi_file% %pkg_dir%


echo Copying Docs
set docs_dir=%new_dir%\docs\%component_name%
copy "%download_dir%\doc\Release Notes.xml"  %docs_dir%

echo Copying Web Services
xcopy /E /R  /Y /Q %download_dir%\AgfaHC.Ris.Web.Services %new_dir%\WebServices\AgfaHC.Ris.Web.Services